<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit Classroom</title>
</head>

<body>

<?php

//get variables passed from index.php
$classroom_id = $_GET['id'];
$building_id = $_GET['bid'];
$building_name = $_GET['name'];
$abbreviation = $_GET['abbrev'];
$room_num = $_GET['room_num'];
$num_seats = $_GET['num_seats'];
$description = $_GET['type'];
$classroom_type_id = $_GET['ctid'];




echo "<h1>UNO Course Scheduler - Edit Classroom in $building_name</h1>";



//initialize variables used to connect to database
$db = "scheduler";
$user = "root";
$pass = "";

//counting variable
$i = 0;

//connect to database
mysql_connect("localhost", $user, $pass);
@mysql_select_db($db);

//select statement
$query="SELECT * FROM classroom_types";
$result=mysql_query($query);

//determine dynamically number of rows read from table
$num_rows=mysql_numrows($result);

//close
mysql_close();

echo '<p>';

echo '<form action="edit_do.php" method="get">';

//start table
echo "<table border='0'>";
	
	//create table row
	echo "<tr>";
		echo "<td><b>Room Number</b></td>";
		echo "<td>";
		echo "<input type='text' name='room_num' value='$room_num'>";
		echo "</td>";
	echo "</tr>";
	
	//create table row
	echo "<tr>";
		echo "<td><b>Seating Capacity</b></td>";
		echo "<td>";
		echo "<input type='text' name='num_seats' value='$num_seats'>";
		echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
		echo "<td><b>Classroom Type</b></td>";
		echo "<td>";
			echo "<select name='type'>";
				while ($i < $num_rows)
				{
					$type_description=mysql_result($result,$i,"description");
					
					if ($type_description == $description)
					{
						echo "<option selected='selected'>$type_description</option>";
					}
					else
					{
						echo "<option>$type_description</option>";
					}
					
					$i++;
				}
			echo "</select>";
	echo "</tr>";

//end table tag
echo "</table>";

echo "<input type='hidden' name='id' value='$classroom_id'>";
echo "<input type='hidden' name='bid' value='$building_id'>";
echo "<input type='hidden' name='name' value='$building_name'>";
echo "<input type='hidden' name='abbrev' value='$abbreviation'>";
echo '<input type="submit">';
echo '</form>';

echo '</p>';

echo "<p>";
	echo "<a href='index.php?id=$building_id&name=$building_name&abbrev=$abbreviation'>&lt;&lt; Back to Classrooms Portal</a><br />";
echo "</p>";

?>

</body>
</html>